using AutoMapper;
using Pay.DTO;
using Pay.Data;
using Pay.IService;
using Pay.Core;

namespace Pay.Service.AutoMapper {
	public class PayInfoMapper : IStartupDto {
		private IMapperConfigurationExpression _cfg;
		public PayInfoMapper(IMapperConfigurationExpression cfg) {
			_cfg = cfg;
		}
		public void Execute() {
			Create();
		}
		protected virtual void Create() {
			_cfg.CreateMap<pay_info_dto, PayInfo>()
				.ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
				.ForMember(dest => dest.OrderNo, src => src.MapFrom(c => c.order_no))
				.ForMember(dest => dest.PayChannel, src => src.MapFrom(c => c.pay_channel))
				.ForMember(dest => dest.PayType, src => src.MapFrom(c => c.pay_type))
				.ForMember(dest => dest.PayCode, src => src.MapFrom(c => c.pay_code))
				.ForMember(dest => dest.PayName, src => src.MapFrom(c => c.pay_name))
				.ForMember(dest => dest.SettleType, src => src.MapFrom(c => c.settle_type))
				.ForMember(dest => dest.PayNo, src => src.MapFrom(c => c.pay_no))
               
                .ForMember(dest => dest.TransactionNo, src => src.MapFrom(c => c.transaction_no))
				.ForMember(dest => dest.CreateTime, src => src.MapFrom(c => c.create_time.ToUnix()))
                 .ForMember(dest => dest.BoardId, src => src.MapFrom(c => c.boardid))
                .ForMember(dest => dest.PlateId, src => src.MapFrom(c => c.plateid))
                .ForMember(dest => dest.PayTime, src => src.MapFrom(c => c.pay_time.ToUnix()));
			_cfg.CreateMap<PayInfo, pay_info_dto>()
				.ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
				.ForMember(dest => dest.order_no, src => src.MapFrom(c => c.OrderNo))
				.ForMember(dest => dest.pay_channel, src => src.MapFrom(c => c.PayChannel))
				.ForMember(dest => dest.pay_type, src => src.MapFrom(c => c.PayType))
				.ForMember(dest => dest.pay_code, src => src.MapFrom(c => c.PayCode))
				.ForMember(dest => dest.pay_name, src => src.MapFrom(c => c.PayName))
				.ForMember(dest => dest.settle_type, src => src.MapFrom(c => c.SettleType))
				.ForMember(dest => dest.pay_no, src => src.MapFrom(c => c.PayNo))
                .ForMember(dest=>dest.orders,src=>src.Ignore())
                .ForMember(dest => dest.boardid, src => src.MapFrom(c => c.BoardId))
                .ForMember(dest => dest.plateid, src => src.MapFrom(c => c.PlateId))
                .ForMember(dest => dest.transaction_no, src => src.MapFrom(c => c.TransactionNo))
				.ForMember(dest => dest.create_time, src => src.MapFrom(c => c.CreateTime.ToDateTime()))
				.ForMember(dest => dest.pay_time, src => src.MapFrom(c => c.PayTime.ToDateTime()));
		}
	}
}
